namespace KPIS.GERP.Models.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class update0135 : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.HrmSystemControls",
                c => new
                    {
                        id = c.Int(nullable: false, identity: true),
                        hrm_sys_control_name = c.String(),
                        hrm_sys_control_value = c.String(),
                    })
                .PrimaryKey(t => t.id);
            
            AddColumn("dbo.hrm_ps_time_attendants", "cal_lastest_success", c => c.Boolean());
            AddColumn("dbo.hrm_ps_time_attendants", "cal_lastest_when", c => c.DateTime());
            AddColumn("dbo.hrm_ps_time_attendants", "cal_lastest_remarks", c => c.String());
            AddColumn("dbo.hrm_ps_time_attendants", "cal_atten_morning", c => c.Boolean());
            AddColumn("dbo.hrm_ps_time_attendants", "cal_atten_morning_late", c => c.Boolean());
            AddColumn("dbo.hrm_ps_time_attendants", "cal_getoff_morning", c => c.Boolean());
            AddColumn("dbo.hrm_ps_time_attendants", "cal_getoff_morning_early", c => c.Boolean());
            AddColumn("dbo.hrm_ps_time_attendants", "cal_atten_afternoon", c => c.Boolean());
            AddColumn("dbo.hrm_ps_time_attendants", "cal_atten_afternoon_late", c => c.Boolean());
            AddColumn("dbo.hrm_ps_time_attendants", "cal_getoff_afternoon_early", c => c.Boolean());
            AddColumn("dbo.hrm_ps_time_attendants", "cal_start_working_time", c => c.Time());
            AddColumn("dbo.hrm_ps_time_attendants", "cal_end_working_time", c => c.Time());
            AddColumn("dbo.hrm_ps_time_attendants", "cal_start_working_time_afternoon", c => c.Time());
            AddColumn("dbo.hrm_ps_time_attendants", "cal_end_working_time_morning", c => c.Time());
            AddColumn("dbo.hrm_ps_time_attendants", "cal_is_atten", c => c.Boolean(nullable: false));
            AddColumn("dbo.hrm_ps_time_attendants", "cal_is_late", c => c.Boolean());
            AddColumn("dbo.hrm_ps_time_attendants", "cal_is_absence_available", c => c.Boolean());
            AddColumn("dbo.hrm_ps_time_attendants", "cal_is_getoff_early", c => c.Boolean());
            AddColumn("dbo.hrm_ps_time_attendants", "cal_cant_calculate", c => c.Boolean(nullable: false));
            AddColumn("dbo.hrm_ps_time_attendants", "cal_reasons_of_cant_calculate", c => c.String());
            AddColumn("dbo.hrm_ps_absence", "PsTimeAttendance_WorkingId", c => c.Int());
            AlterColumn("dbo.hrm_ps_time_att_monthly", "actual_working_day_count", c => c.Decimal(precision: 18, scale: 2));
            AlterColumn("dbo.hrm_ps_time_att_monthly", "late_day_count", c => c.Decimal(precision: 18, scale: 2));
            AddForeignKey("dbo.hrm_ps_absence", "PsTimeAttendance_WorkingId", "dbo.hrm_ps_time_attendants", "working_seq");
            CreateIndex("dbo.hrm_ps_absence", "PsTimeAttendance_WorkingId");
            DropColumn("dbo.hrm_ps_time_attendants", "working_status");
            DropColumn("dbo.hrm_ps_time_att_monthly", "sick_day_count");
            DropColumn("dbo.hrm_ps_time_att_monthly", "private_day_count");
            DropColumn("dbo.hrm_ps_time_att_monthly", "vacation_day_count");
            DropColumn("dbo.hrm_ps_time_att_monthly", "sick_count");
            DropColumn("dbo.hrm_ps_time_att_monthly", "quota_vacation");
            DropColumn("dbo.hrm_ps_time_att_monthly", "deliver_day_count");
            DropColumn("dbo.hrm_ps_time_att_monthly", "edu_day_count");
            DropColumn("dbo.hrm_ps_time_att_monthly", "ordain_day_count");
            DropColumn("dbo.hrm_ps_time_att_monthly", "temp_day_count");
        }
        
        public override void Down()
        {
            AddColumn("dbo.hrm_ps_time_att_monthly", "temp_day_count", c => c.Int());
            AddColumn("dbo.hrm_ps_time_att_monthly", "ordain_day_count", c => c.Int());
            AddColumn("dbo.hrm_ps_time_att_monthly", "edu_day_count", c => c.Int());
            AddColumn("dbo.hrm_ps_time_att_monthly", "deliver_day_count", c => c.Int());
            AddColumn("dbo.hrm_ps_time_att_monthly", "quota_vacation", c => c.Int());
            AddColumn("dbo.hrm_ps_time_att_monthly", "sick_count", c => c.Int());
            AddColumn("dbo.hrm_ps_time_att_monthly", "vacation_day_count", c => c.Decimal(precision: 18, scale: 2));
            AddColumn("dbo.hrm_ps_time_att_monthly", "private_day_count", c => c.Decimal(precision: 18, scale: 2));
            AddColumn("dbo.hrm_ps_time_att_monthly", "sick_day_count", c => c.Decimal(precision: 18, scale: 2));
            AddColumn("dbo.hrm_ps_time_attendants", "working_status", c => c.String());
            DropIndex("dbo.hrm_ps_absence", new[] { "PsTimeAttendance_WorkingId" });
            DropForeignKey("dbo.hrm_ps_absence", "PsTimeAttendance_WorkingId", "dbo.hrm_ps_time_attendants");
            AlterColumn("dbo.hrm_ps_time_att_monthly", "late_day_count", c => c.Int());
            AlterColumn("dbo.hrm_ps_time_att_monthly", "actual_working_day_count", c => c.Int());
            DropColumn("dbo.hrm_ps_absence", "PsTimeAttendance_WorkingId");
            DropColumn("dbo.hrm_ps_time_attendants", "cal_reasons_of_cant_calculate");
            DropColumn("dbo.hrm_ps_time_attendants", "cal_cant_calculate");
            DropColumn("dbo.hrm_ps_time_attendants", "cal_is_getoff_early");
            DropColumn("dbo.hrm_ps_time_attendants", "cal_is_absence_available");
            DropColumn("dbo.hrm_ps_time_attendants", "cal_is_late");
            DropColumn("dbo.hrm_ps_time_attendants", "cal_is_atten");
            DropColumn("dbo.hrm_ps_time_attendants", "cal_end_working_time_morning");
            DropColumn("dbo.hrm_ps_time_attendants", "cal_start_working_time_afternoon");
            DropColumn("dbo.hrm_ps_time_attendants", "cal_end_working_time");
            DropColumn("dbo.hrm_ps_time_attendants", "cal_start_working_time");
            DropColumn("dbo.hrm_ps_time_attendants", "cal_getoff_afternoon_early");
            DropColumn("dbo.hrm_ps_time_attendants", "cal_atten_afternoon_late");
            DropColumn("dbo.hrm_ps_time_attendants", "cal_atten_afternoon");
            DropColumn("dbo.hrm_ps_time_attendants", "cal_getoff_morning_early");
            DropColumn("dbo.hrm_ps_time_attendants", "cal_getoff_morning");
            DropColumn("dbo.hrm_ps_time_attendants", "cal_atten_morning_late");
            DropColumn("dbo.hrm_ps_time_attendants", "cal_atten_morning");
            DropColumn("dbo.hrm_ps_time_attendants", "cal_lastest_remarks");
            DropColumn("dbo.hrm_ps_time_attendants", "cal_lastest_when");
            DropColumn("dbo.hrm_ps_time_attendants", "cal_lastest_success");
            DropTable("dbo.HrmSystemControls");
        }
    }
}
